import { createRouter, createWebHistory } from 'vue-router'

const routes = [
  {
    path: '/',
    name: 'Layout',
    component: () => import('../views/Layout.vue'),
    redirect: '/mock',
    children: [
      {
        path: '/mock',
        name: 'MockList',
        component: () => import('../views/mock/MockList.vue'),
        meta: { title: 'Mock API管理' }
      },
      {
        path: '/mock/create',
        name: 'CreateMock',
        component: () => import('../views/mock/MockForm.vue'),
        meta: { title: '创建Mock API' }
      },
      {
        path: '/mock/edit/:id',
        name: 'EditMock',
        component: () => import('../views/mock/MockForm.vue'),
        meta: { title: '编辑Mock API' }
      },
      {
        path: '/logs',
        name: 'RequestLogs',
        component: () => import('../views/logs/RequestLogs.vue'),
        meta: { title: '请求历史记录' }
      },
      {
        path: '/logs/:id',
        name: 'LogDetail',
        component: () => import('../views/logs/LogDetail.vue'),
        meta: { title: '请求详情' }
      },
      {
        path: '/import-export',
        name: 'ImportExport',
        component: () => import('../views/ImportExport.vue'),
        meta: { title: '导入导出' }
      }
    ]
  },
  {
    path: '/:pathMatch(.*)*',
    name: 'NotFound',
    component: () => import('../views/NotFound.vue')
  }
]

const router = createRouter({
  history: createWebHistory(),
  routes
})

export default router